package cn.jingyuan.owl.web.oauth2.exception;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

import java.io.IOException;

public class DefaultOAuth2ExceptionSerializer extends StdSerializer<DefaultOAuth2Exception> {

    public DefaultOAuth2ExceptionSerializer() {
        super(DefaultOAuth2Exception.class);
    }

    @Override
    public void serialize(DefaultOAuth2Exception ex, JsonGenerator gen, SerializerProvider provider) throws IOException {
        Result rs = DefaultOAuth2ExceptionSupport.resolve(ex);
        gen.writeObject(rs);
    }

}
